#include<bits/stdc++.h>
#include<cmath>
using namespace std;
long long int n,m,l,vm,cnt;
const int N=1e5;
long long int ms[N],cnts[20];
struct Car
{
    int d,v,a;
    bool f=0;
    int cd;
    int call[N];
};
int main()
{
    int t;
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>n>>m>>l>>vm;
        Car cars[n];
        for(int j=0;j<N;j++) ms[j]=0;
        for(int j=0;j<n;j++)
        {
            cin>>cars[j].d>>cars[j].v>>cars[j].a;
        }
        for(int j=0;j<m;j++)
        {
            cin>>ms[j];
        }
        for(int j=0;j<n;j++)
        {
            if(cars[j].v>vm)
            {
                int vec;
                double vmax;
                for(int k=0;k<m;k++)
                {
                    if(ms[k]>=cars[j].d)
                    {
                        vec=k;
                        break;
                    }
                }
                vmax=sqrt(cars[j].v*cars[j].v+2*cars[j].a*(ms[vec]-cars[j].d));
                if(vmax>vm)
                {
                    cars[j].f=1;
                    cars[j].cd=vec;
                    if(cars[j].a>=0)
                    {
                        for(int x=vec;x<m;x++)
                        {
                            cars[j].call[x-vec]=ms[vec];
                            cars[j].cd=x-vec;
                        }
                    }
                    else
                    {
                        int point=m-1;
                        for(int k=vec+1;k<m;k++)
                        {
                            if(sqrt(cars[j].v*cars[j].v+2*cars[j].a*(ms[k]-cars[j].d))<vm)
                            {
                                point=k;
                                break;
                            }
                        }
                        for(int k=vec;k<point;k++)
                        {
                            cars[j].call[k-vec]=ms[k];
                            cars[j].cd=k-vec;
                        }
                    }
                }
            }
            else if(cars[j].v=vm)
            {
                if(cars[j].a>0)
                {
                    cars[j].f=1;
                    for(int k=0;k<m;k++)
                    {
                        if(ms[k]>=cars[j].d)
                        {
                            cars[j].cd=ms[k];
                            for(int x=k;x<m;x++)
                            {
                                cars[j].call[x-k]=ms[x];
                                cars[j].cd=x-k;
                            }
                            break;
                        }
                    }
                }
            }
            else
            {
                int vec;
                for(int k=0;k<m;k++)
                {
                    if(ms[k]>=cars[j].d)
                    {
                        int vmax=sqrt(cars[j].v*cars[j].v+2*cars[j].a*(ms[k]-cars[j].d));
                        if(vmax>vm)
                        {
                            cars[j].f=1;
                            cars[j].cd=ms[k];
                            for(int x=k;x<m;x++)
                            {
                                cars[j].call[x-k]=ms[x];
                                cars[j].cd=x-k;
                            }
                            break;
                        }
                    }
                }
            }
        }
        cnt=0;
        for(int j=0;j<n;j++)
        {
            if(cars[j].f==1)
            {
                cnt++;
            }
        }
        cnts[i]=cnt;
    }
    for(int i=0;i<t;i++)
    {
        cout<<cnts[i]<<endl;
    }
    return 0;
}